<?php
namespace app\closure\model;

use app\BaseModel;
use think\facade\Db;

class AdminClosure extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_closure';



    public function getTokenAttr($value){

        return json_decode($value);

    }
    /**
     * User: chenniang
     * Date: 2019-12-18 14:11
     * @return void
     * descrption:配置详情
     */
    public function closureInfo($dis){
        $data = $this->where($dis)->find();
        if(empty($data)){

            $this->closureAdd($dis);
            $data = $this->where($dis)->find();
        }
        return $data->toArray();
    }

    /**
     * User: chenniang
     * Date: 2019-12-18 14:11
     * @return void
     * descrption:添加配置
     */
    public function closureAdd($data){
        $data['create_time'] = time();
        $data['update_time'] = time();
        $data['status']      = 0;
        $data['token']       = '';
        $res = $this->insert($data);
        return $res;
    }

    /**
     * User: chenniang
     * Date: 2019-12-18 14:13
     * @return void
     * descrption:编辑配置
     */
    public function closureUpdate($dis,$data){
        $data['update_time'] = time();
        $res = $this->where($dis)->update($data);
        return $res;
    }










}